<!-- src/components/Navbar.vue -->
<template>
  <nav class="navbar">
    <div class="navbar-brand">任务看板系统</div>
    <div class="navbar-user" v-if="userStore.currentUser">
      欢迎, {{ userStore.currentUser }}
      <button @click="handleLogout" class="logout-button">登出</button>
    </div>
  </nav>
</template>

<script setup>
import { useUserStore } from '../stores/userStore'
import { useRouter } from 'vue-router'

const userStore = useUserStore()
const router = useRouter()

const handleLogout = () => {
  userStore.logout()
  router.push('/login')
}
</script>

<style scoped>
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  font-weight: bold;
  font-size: 1.2rem;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logout-button {
  padding: 5px 10px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  cursor: pointer;
}

.logout-button:hover {
  background: #e9ecef;
}
</style>